package basic.io;

import java.io.File;
import java.io.FilenameFilter;

public class FirstFileDemo {

	public static void main(String[] args) {
		FirstFileDemo fileDemo = new FirstFileDemo();
		File file = new File("F:\\");
		fileDemo.method1(file);
		/*
		 * fileDemo.method2(); fileDemo.testSubString();
		 */
	}

	public void method1(File file) {
		File[] fileAray = file.listFiles();
		for (File f : fileAray) {
			if (f.isDirectory()) {
				method1(f);
			} else {
				 System.out.println(f.getAbsolutePath());
			}

		}
		
	}

	public void method2() {
		System.out.println("method2.......");
		File file = new File("f:\\");
		String[] filenames = file.list(new FilenameFilter() {

			@Override
			public boolean accept(File dir, String name) {
				return new File(dir, name).isFile() && name.endsWith(".zip");
			}
		});
		for (String name : filenames) {
			System.out.println(name);
		}
	}

	public void testSubString() {
		String name = "123_456_789";
		int lastIndex = name.lastIndexOf("_");
		String newString = name.substring(lastIndex);
		System.out.println("newString" + newString);
	}

}
